*************************************************************
*Correlation between the two calculations of the theil index
use temp1,clear
log using $DIRLOG/Replication/theilagg_vs_w_corr.txt, text replace
*
gen theil_diff = theilw-theil1agg_w
list firmid year iso2_d nbnc8 if theil_diff/theil1agg_w>0.01 & theil_diff!=.
gen byte badmerge = theil_diff/theil1agg_w>0.01 & theil_diff!=.
corr theilw theil1agg_w
global coef = round(r(rho),0.01)
*
scatter theilw theil1agg_w if badmerge==0, msymbol(p) text(5 1 "Correlation Coeff = $coef") scheme(mys2color)
graph export $DIRLOG/Replication/theil1agg_vs_w_corr.png, as(png) replace
drop badmerge
*
log close
